//	ID : pallab81
// 	PROG : DSUBSEQ
// 	LANG : C++
// 	2011-06-27-20.44.30 Monday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define  CI( x ) scanf( "%d", &x )

#define VI vector<int>
#define VVI vector<VI >
#define VS vector<string>
#define VC vector<char>
#define VVC vector<VC >
#define VB vector<bool>
#define VVB vector<VB >
#define PAIR pair<int,int>
#define VP vector<PAIR >
#define fo(i,st,ed) for(int i = st; i < ed ; ++i)
#define foE(i,st,ed) for(int i = st; i <= ed ; ++i)
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define mk make_pair
#define f first
#define s second
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define Int int
#define IO ifstream cin(".in") ; ofstream cout(".out");

/*
    algorithm I used to solve this problem
    http://docs.google.com/viewer?a=v&q=cache:er14e6XciNwJ:compalg.inf.elte.hu/~tony/Kutatas/PerfectArrays/Elzinga-AlgorithmsSubsequenceCombinatorics.pdf+count+the+number+of+distinct+subsequences&hl=en&pid=bl&srcid=ADGEESj351yNOyEYjCc6Cb5vGP5KX3QH93AMv3LB1s_O1lbxZRBJfElHODZLE06vjJdKNVCovkCB9k3DAYrq2Jzu5JLZG0K2ggx9c4tsDqktFkosYBDHLK8yMPSkLzj3L0DkL9jLn7rZ&sig=AHIEtbQn50xUb7seK5P7SqZtEMKFII8gjQ
*/
const Int mod = 1000000007;
const Int inf = 100000 ;
char input[ inf+100 ];
Int l[ inf+100 ], N[ inf+100 ];

inline void doit(){
    memset( l , 0, sizeof(l) );
    foE(i,0,inf)N[i]=1;

    gets(input);
    int i; //trace the array length
    for(i = 1; char ch = input[i-1] ;++i){
        N[i] = 2*N[i-1];
        if( l[ ch ] > 0 ){
            N[i] =  N[i] - N[ l[ ch ] - 1 ];
        }
        l[ ch ] = i;
        if(N[i]<0)N[i]+=mod;
        if(N[i]>=mod)N[i]-=mod;
    }

    printf("%d\n",N[ i-1 ] );

}
int main(){
    int cases;
    scanf("%d\n",&cases);
    while(cases--){
        doit();
    }

return 0;
}

